﻿CREATE TABLE [dbo].[CoachDB] (
    [Inventory_Number]        NVARCHAR (8)  NOT NULL,
    [Cargo_Weight]            NVARCHAR (3)  NOT NULL,
    [Destination]             NVARCHAR (5)  NOT NULL,
    [Good_Code]               NVARCHAR (5)  NOT NULL,
    [Receiver_Code]           NVARCHAR (4)  NOT NULL,
    [Park_Type]               NVARCHAR (2)  NOT NULL,
    [Start_Station]           NVARCHAR (5)  NOT NULL,
    [Operation_Code]          NVARCHAR (2)  NOT NULL,
    [Operation_Data]          NVARCHAR (4)  NOT NULL,
    [Operation_Year]          NVARCHAR (2)  NOT NULL,
    [Operation_Time]          NVARCHAR (4)  NOT NULL,
    [Station_Of_Operation]    NVARCHAR (5)  NOT NULL,
    [Delivery_Road]           NVARCHAR (2)  NOT NULL,
    [Reception_Road]          NVARCHAR (2)  NOT NULL,
    [Coach_Index]             NVARCHAR (13) NOT NULL,
    [Coach_Number]            NVARCHAR (4)  NOT NULL,
    [Destionation_FK]         NVARCHAR (7)  NOT NULL,
    [Good_Code_FK]            NCHAR (5)     NOT NULL,
    [Receiver_Code_FK]        NCHAR (4)     NOT NULL,
    [Start_Station_FK]        NVARCHAR (7)  NOT NULL,
    [Operation_Code_FK]       NCHAR (2)     NOT NULL,
    [Station_Of_Operation_FK] NVARCHAR (7)  NOT NULL,
    [Delivery_Road_FK]        NVARCHAR (50) NOT NULL,
    [Reception_Road_FK]       NVARCHAR (50) NOT NULL,
    CONSTRAINT [FK_CoachDB_Cargo] FOREIGN KEY ([Good_Code_FK]) REFERENCES [dbo].[Cargo] ([ShortCode]),
    CONSTRAINT [FK_CoachDB_CarOperation] FOREIGN KEY ([Operation_Code_FK]) REFERENCES [dbo].[CarOperation] ([Code]),
    CONSTRAINT [FK_CoachDB_Road] FOREIGN KEY ([Delivery_Road_FK]) REFERENCES [dbo].[Road] ([Code]),
    CONSTRAINT [FK_CoachDB_Road2] FOREIGN KEY ([Reception_Road_FK]) REFERENCES [dbo].[Road] ([Code]),
    CONSTRAINT [FK_CoachDB_ShipmentClient] FOREIGN KEY ([Receiver_Code_FK]) REFERENCES [dbo].[ShipmentClient] ([Code]),
    CONSTRAINT [FK_CoachDB_Station] FOREIGN KEY ([Destionation_FK]) REFERENCES [dbo].[Station] ([Code]),
    CONSTRAINT [FK_CoachDB_Station2] FOREIGN KEY ([Start_Station_FK]) REFERENCES [dbo].[Station] ([Code]),
    CONSTRAINT [FK_CoachDB_Station3] FOREIGN KEY ([Station_Of_Operation_FK]) REFERENCES [dbo].[Station] ([Code])
);

